<!DOCTYPE html>
<?php
	//include_once("header.php");
	//include_once("bottom.php");
	@session_start();
?>
<html lang="zh-hk">
	<?php
	include_once("../manager/UserManager.php");
	include_once("../db/User.php");

	$flag = 0;
	if( isset($_POST['username'])) {
		$username = $_POST['username'];
		$password = $_POST['password'];
		$nickname = $_POST['nickname'];
		
		$array = array('Username'=>$username, 'Password'=>$password, 'Nickname'=>$nickname);
		
		UserManager::getInstance()->register($array);
		$UserID = UserManager::getInstance()->getIDByUsername($username);

		// 获得当前注册后的用户，以便后面的页面得到当前登录的用户
		$_SESSION['currentUser'] = $username;
		$_SESSION['currentID'] = UserManager::getInstance()->getIDByUsername($username);
	}
	else
		//
		$flag = 1;
	
	
	?>
	
	<head>
		<title>TINY bOOk</title>
		<meta http-equiv="Content-Type" content="text/html charset=UTF-8">
		<meta name="contentType" value="text/html  charset=GBK">
		<meta name="description" content="在这里你可以看到最新发布的书籍，和好友共享对某本书的评论和笔记">
		<meta http-equiv="imagetoolbar" content="no">
		<meta name="viewport" content="width=1036">
		
		<link rel="stylesheet" type="text/css" href="../css/result.css"/>
		<link rel="shortcut icon" href="images/shortcut.jpg"/>
		
		<?php
			if ($flag === 0)
			{
				if ($username === "manager")
				{
		?>
					<<meta http-equiv="refresh" content="1; url=adminPage.php">
		<?php
				}else
				{
				?>
					<meta http-equiv="refresh" content="1; url=mainPage.php">
				<?php
				}
			}
		?>
	</head>	
		
	<body>
		<div id="title"  class="banner">
			<h1>TINY bOOk</h1>
		</div>
		<div id="welcome">
			<h2>欢迎成为TINY bOOk的成员</h2>
		</div>

		<div id="hasRegister">
			<p>已注册，跳转到主页面</a></p>
		</div>
	</body>
</html>